package com.hxx.day7;

import org.junit.Test;

public class TestDemo {
    /**
     * 继承的方式完成线程的创建
     * 启动线程start-自动调用run方法
     */
    @Test
    public void test1(){
        TestDemo1 testDemo1 = new TestDemo1();
        //启动线程-自动调用run方法
        testDemo1.start();
    }
    /**
     * 实现的方式完成线程的创建
     */
    @Test
    public void test2() {
        Runnable runnable = () -> System.out.println("线程2");
        Thread thread = new Thread(runnable);
        thread.start();
    }
    @Test
    public void test() {
       new Thread(() -> System.out.println("编写一行完成线程")).start();
    }

}

class TestDemo1 extends Thread{
    @Override
    public void run() {
        System.out.println("线程1");
    }
}
